<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
// 制定允许其他域名访问
header("Access-Control-Allow-Origin:*");
// 响应类型
header('Access-Control-Allow-Methods:POST');
// 响应头设置
header('Access-Control-Allow-Headers:x-requested-with, content-type');
ini_set('date.timezone', 'Asia/Shanghai');
session_start();
include (dirname(dirname(__FILE__)) . "/zhconfig/Config.php");

$openid = SafeRequest(getPGC("openid"), 0);
$token = SafeRequest(getPGC("token"), 0);

$returnS = array(
    'code' => '0',
    'data' => '',
    'msg' => 'ok',
    'message' => '成功请求',
    'updateDime' => intval(time())
);

if ($openid != "") {
    $rs_user = new \MALL\D\User();
    $data_user = $rs_user->getOne1("openid='" . $openid . "'");
    $row_user = $rs_user->getRows();
    if ($row_user > 0) {
        $tokens = $data_user['tokens'];
        $newtoken = md5(SIGNATURENEW . $openid . $tokens);
        if ($newtoken !== $token) {
            $returnS['msg'] = 'openid empty';
            $returnS['message'] = "非法";
            $returnS['code'] = "1";
            $result = json_encode($returnS);
            echo $result;
            exit();
        }
        else
        {
            
        }
    }
    else
    {
        $returnS['code'] = '1';
        $returnS['msg'] = 'user no';
        $returnS['message'] = 'openid不存在';
        $result = json_encode($returnS);
        echo $result;
        exit();
    }
    $rs_user=null;
}
else {
    $returnS['code'] = '1';
    $returnS['msg'] = 'openid empty';
    $returnS['message'] = '上级openid为空';
    $result = json_encode($returnS);
    echo $result;
    exit();
}